<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增房屋信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-room-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">楼栋名字：</label>
                <div class="col-sm-8">
                <select name="fId" onchange="floorChange()" id="fId" class="form-control m-b">
                    <option  value="">请选择</option>
                    <option th:each="floor : ${floorSelectAdd}"  th:text="${floor.name}" th:value="${floor.floorId}"></option>
                </select>
            </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">单元编号：</label>
                <div class="col-sm-8">
                    <select id="uid" class="form-control m-b"  name="unitId">
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">房屋编号：</label>
                <div class="col-sm-8">
                    <input name="roomNum" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">层数：</label>
                <div class="col-sm-8">
                    <input name="layer" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">户型：</label>
                <div class="col-sm-8">
                    <input name="apartment" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">建筑面积：</label>
                <div class="col-sm-8">
                    <input name="builtUpArea" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text" >
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "system/room"
        $("#form-room-add").validate({
            focusCleanup: true
        });
        function floorChange(){
            var fid=$("#fId").val();
            $.ajax({url:"/system/room/untilSelect",type:"get",data:"floorId="+fid,async:true,success:function (reslut) {
                    if (reslut!="") {
                        $("#uid").text("");

                        $("#uid").append("<option selected='selected' value=''>请选择</option>");
                        $.each($.parseJSON(reslut), function (index, item) {

                            $("#uid").append("<option  value='" + item.unitId + "'>" + item.unitNum + "</option>");

                        });
                    }else{
                        $("#uid").text("");
                    }

                },error:function (reslut) {
                    layer.msg("操作失败", {icon: 2});
                }
            });
        }
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-room-add').serialize());
            }
        }
    </script>
</body>
</html>